<?php
if(!defined ('BASEPATH')) exit('No Access !!!');

class M_absensi extends CI_Model{

	function __construct(){
		parent::__construct();
		
	}
    
    function save($data){
        
        
        
         $this->db->insert('absen',$data);
         
    }
    
    function getdata(){//mengambil data berdasar seluruh isi tabel
        $this->db->select('*')->from('absen')->order_by('ID_ABSEN ASC');
        $query=$this->db->get();
        return $query->result();
    }
	
	function getdata_json(){//mengambil data berdasar seluruh isi tabel
        $this->db->select('*')->from('absen')->order_by('ID_ABSEN ASC');
        $query=$this->db->get();
        return $query->result_array();
    }
    
   	public function getById($id_absen){	//mengambil data dari db berdasarkan   id (primary key)
		return $this->db->get_where('absen',array('ID_ABSEN'=>$id_absen))->row();
	}

    function hapus($id_absen){
        $this->db->delete('absen',array('ID_ABSEN'=>$id_absen));  
    }
    
     function update($id_user){
	 
	 
     $jam_masuk = date('Y-m-d');
     $jam_pulang = date('Y-m-d H:i:s');
     $path_foto2 = $this->input->post('path_foto');

     $data3 = array ( 'JAM_PULANG'=>$jam_pulang,'PATH_FOTO2'=>$path_foto2);
     $this->db->where(array('JAM_MASUK LIKE'=>"%" . date('Y-m-d') . "%",'ID_USER'=>$id_user));
     $this->db->update('absen',$data3);
    }

    function getid($id_user){ //mengambil data berdasar primary key ID_ABSEN tabel
        $this->db->like('JAM_MASUK',date('Y-m-d'));
        $this->db->where('ID_USER',$id_user);
        $a=$this->db->get('absen');
        return $a->result();
    }

    function caridata(){
        $c = $this->input->post('search');
        $this->db->like('ID_USER', $c);
        $query = $this->db->get('absen');
        return $query->result(); 
    }
  
   }
?>